async function checkPassword(event) {
  event.preventDefault(); // 阻止默认的链接跳转行为

  // 存储SHA-256哈希后的密码，防止源码暴露密码明文
  const storedHash = "872ef0d3ad74d140df9f3fa88fb65a924f8b38509c375d712a7096759eb33fa3";

  const userInput = prompt("请输入下载密码:");
  if (userInput === null) return; // 用户点击取消

  // 计算用户输入的SHA-256哈希
  const encoder = new TextEncoder();
  const data = encoder.encode(userInput);
  const hashBuffer = await crypto.subtle.digest('SHA-256', data);
  const hashArray = Array.from(new Uint8Array(hashBuffer));
  const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');

  if (hashHex === storedHash) {
    // 密码正确，创建临时下载链接
    const link = document.createElement('a');
    link.href = '简历.pdf';
    link.download = '简历.pdf';
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
  } else {
    alert("密码错误，请重试!");
  }
}

// 监听锚点链接的点击事件，弹出验证窗口
document.getElementById('download_cv').addEventListener('click', checkPassword);